/***************************************************************************
 *   Copyright (C) 2006 by Sergey Melderis   *
 *   sergey.melderis@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef BROWSERPOPUPMENU_H
#define BROWSERPOPUPMENU_H

#include <qobject.h>
class QPopupMenu;
class QString;
/**
	@author Sergey Melderis <sergey.melderis@gmail.com>
	BrowserPopupMenu is not actually a Menu, but it has QPopupMenu.
*/
class BrowserPopupMenu : public QObject
{
Q_OBJECT
public:
    BrowserPopupMenu(QObject *parent = 0, const char *name = 0);

    ~BrowserPopupMenu();

    /**
        Sets current word to the menu.
    */
    void setCurrentWord(const QString &word);

    /**
        Sets current translation for the word.
    */
    void setCurrentTranslation(const QString &transl);

    /**
        Returns the current word.
    */
    QString& currentWord();

    /**
        Adds new file key item.
    */
    void addFileKeyItem(const QString &name);

    /**
        Clear all file keys/
    */
    void clearFileKeys();

    /**
        Returns the actual QPopupMenu that can be popuped up.
    */
    QPopupMenu *popupMenu();

    /**
        Menu reads key values for files from FilesPrefs and sets the menu.
     */
    void reconfigure();
signals:
    /**
        The signal is emitted on request to translate a word.
    */
    void translateActivated(const QString &word);

    /**
        The signal is emitted on request to add current word and translation to the wordquizfile.
    */
    void addToFileActivated(const QString &fileName, const QString &word, const QString &transl);

    void requestAddWordQuizFiles();

private slots:
    void emitTranslate(int id);

    void emitAddToFile(int id);

    void setUpContent();
private:
    QString mCurrentWord;
    QString mCurrentTranslation;

    QPopupMenu *mMenu;

    //File submenu.
    QPopupMenu *mFileMenu;

    //id for the Add to menu item.
    static const int ADD_TO_ID = 99;

    static const int TRANSLATE_ID = 1;

};

#endif
